package com.hefei.garden.controller;

import com.hefei.garden.pojo.domain.UserInfo;
import com.hefei.garden.pojo.dto.UserInfoDto;
import com.hefei.garden.pojo.response.ResultCode;
import com.hefei.garden.pojo.response.ResultVo;
import com.hefei.garden.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author: devil
 * @Date: 2022/7/3 17
 * @Description: 用户信息接口
 */
@RequestMapping("userInfo")
@Controller
public class UserInfoController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/insertUserInfo", method = RequestMethod.POST)
    @ResponseBody
    public ResultVo insertUserInfo(@RequestBody UserInfo userInfo) {
        userService.insertUserInfo(userInfo);
        return new ResultVo(ResultCode.SUCCESS);
    }

    @RequestMapping(value = "/getUserInfoByParam", method = RequestMethod.POST)
    @ResponseBody
    public ResultVo getUserInfo(@RequestBody UserInfoDto userInfoDto) {
        List<UserInfo> user = userService.getUserInfoByParam(userInfoDto);
        return new ResultVo(ResultCode.SUCCESS, user);
    }




}
